<?php
declare (strict_types = 1);

namespace app\admin\model;

use think\Model;

/**
 * @mixin \think\Model
 */
class CityArea extends Model
{
    protected $pk = "id";


    /**
     * 获取名称
     * @param $id
     * @return array|null|Model
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    function getNameById($id){
        return $this->where('id',$id)->value('name');
    }

    /**
     * 获取地区列表
     * @param $where
     * @param $page
     * @param $limit
     * @param string $field
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    function getList($where,$page,$limit,$field='*'){
        return $this->where($where)->field($field)->page($page,$limit)->select()->toArray();
    }

    /**
     * 获取地区列表
     * @param $where
     * @param $field
     * @return array
     * @throws \think\db\exception\DataNotFoundException
     * @throws \think\db\exception\DbException
     * @throws \think\db\exception\ModelNotFoundException
     */
    function getAllList($where,$field='*'){
        return $this->where($where)->field($field)->select()->toArray();
    }




}
